<script src="__PUBLIC__/home/js/count.js"></script>
<style>
    body {
        background: #f5f5f5;
    }
    .news_li a, .swap a{
        color: #fff;
    }
    .swap li{
        color: #fff;
    }
    .news_li{
        color: #fff;
    }
    .index_section2 .swiper-slide .a1{
        padding: 5px 0px;
        margin-bottom: 20px;
    }
    .index_section2 .swiper-slide .a2 .pic{
        padding-top: 0px;
        background: #b9d4ff;
        border-top-left-radius: 5px;
        border-top-right-radius: 5px;
    }
    .index_section4 .b1{
        padding: 5px 0px;
        margin-bottom: 15px;
        margin-top: 15px;
    }
    .index_section4 .a2_1{

    }
    .index_section4 .a1{
        margin-top: 20px;
    }
    .index_section4 .a2_1{
        margin-top: 10px;
    }
</style>
<div class="index_section1" style="padding-bottom: 15px;padding-top: 25px;">
    <div class="index_section1_1 clearfix" style="background: #4587e9;">
        <div class="left">
            <img src="__PUBLIC__/home/images/a8.png" alt="">
        </div>
        <div class="right clearfix">
            <div class="ko">
                <ul class="news_li">
					{foreach $newlist as $v}
                    <li class="chao">
                        <a href="{:url('News/details')}?id={$v.id}">{$v.title}</a>
                    </li>
					{/foreach}
                </ul>
                <ul class="swap"></ul>
            </div>
        </div>
    </div>
</div>
<div class="index_section2" style="margin-top: 10px;">
    <input type="hidden" value="{:time()}" id="now_time">
    <input type="hidden" value="{$return_id}" id="return_id">
    <input type="hidden" value="{$return_time}" id="return_time">
    <div class="ppp">
        <div class="swiper-container" id="mm">
            <div class="swiper-wrapper">
                {foreach $goods_list as $good}
                    <div class="swiper-slide  good_{$good.id}">
                        <div class="a1">
                            <p class="p1">{$good.title}</p>
                        </div>
                        <div class="a2">
                            <div class="pic">
                                <img src="{$good.img_url}" alt="">
                            </div>
                            <div class="text clearfix">
                                <div class="left">
                                    <p class="p1">价值 {$good.price1}-{$good.price2}</p>
                                    <p class="p2">获得{$good.botnum}枚SCB</p>
                                </div>
                                <div class="right  item_last{$good.id}">
                                    {if $good.can_sale eq 1}
                                    <span class="s1"  data-id="{$good.id}" {if $good.over_status eq 0}onclick="buyproduct('{$good.id}')"{/if}>{$good.over_text}</span>
                                    {elseif $good.can_sale eq 2}
                                    <span class="s1">待开放</span>
                                    {/if}

                                </div>
                            </div>
                        </div>
                    </div>
                {/foreach}
            </div>
            <div class="swiper-pagination"></div>
        </div>
    </div>
</div>
<div class="index_section4 ">
    <div class="ppp">
        <div class="swiper-container" id="tt">
            <div class="swiper-wrapper">
                {foreach $goods_list as $good2}
                <div class="swiper-slide clearfix">
                    <div class="b1 clearfix">
                        <ul class="clearfix">
                            <li>
                                <p class="p1">预约共享豆</p>
                                <p class="p2">{$good2.point_start}</p>
                            </li>
                            <li>
                                <p class="p1">开放时间</p>
                                <p class="p2">{:date('H:i', $good2.start_time)}-{:date('H:i', $good2.end_time)}</p>
                            </li>
                            <li>
                                <p class="p1">合约收益</p>
                                <p class="p2">{$good2.daynum}天/{$good2.daypercent}%</p>
                            </li>
                        </ul>
                    </div>
                    <div class="a1">
                        <p class="p1">{$good2.title}简介</p>
                    </div>
                    <div class="a2">
                        <div class="a2_1 sel_height">
                            <p class="p1">{$good2.desc}</p>
                        </div>
                    </div>
                </div>
                {/foreach}
            </div>
        </div>
    </div>
</div>
{include file='public/footer'}
<!-- 公告 -->
{if $show_info eq 1}
<div class="alert_gong" style="display: block!important;">
    <div class="alert_gong_1">
        <div class="a1">
            <div class="title">
                <p class="p1">
                    <span class="s1">{$info.title|default='公告'}</span>
                </p>
            </div>
            <div class="center">
                <p class="p1">{$info.content|default=''}</p>
            </div>
        </div>
        <div class="a2">
            <img src="__PUBLIC__/home/images/a15.png" class="close_alert_gong" alt="">
        </div>
    </div>
</div>
{/if}
<!-- 提示 -->
<div class="alert_ti" style="display: none;">
    <div class="alert_ti_1">
        <div class="a1">
            <div class="title">
                <p class="p1">
                    <span class="s1">提示</span>
                </p>
            </div>
            <div class="center">
                <p class="p1 apply_result"></p>
            </div>
            <div class="last">
                <button class="but1 close_alert_ti">确定</button>
            </div>
        </div>
<!--        <div class="a2">-->
<!--            <img src="__PUBLIC__/home/images/a15.png" class="close_alert_ti" alt="">-->
<!--        </div>-->
    </div>
</div>
<!--轮播联动-->
<!-- 判断高度不滑动 -->
<script>
    $(function(){
        var dd =$(window).height();
        if(dd<569){
            $("body").css("height",(dd));
            $("body").css("overflow","hidden");
        }
        $(".sel_height").css("height",($(window).height()-650))
    })
</script>
<script>
    var swiper1 = new Swiper('#mm', {
        spaceBetween: 30,
        centeredSlides: true,
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
        initialSlide:{$slider}
    });
    var swiper2 = new Swiper('#tt', {
        spaceBetween: 30,
        centeredSlides: true,
        initialSlide: {$slider}
    });
    swiper1.controller.control = swiper2;
    swiper2.controller.control = swiper1;
</script>
<script>
    $(function () {
        $(".close_alert_gong").click(function () {
            $(".alert_gong").hide()
        })
        $(".close_alert_ti").click(function () {
            $(".alert_ti").hide()
        })
        var index = layer.load(1, {
            time: {$load_time},
            shade: [0.8, '#000'] //0.1透明度的白色背景
        })
    })
</script>
<!--新闻滚动-->
<script>
    function b() {
        t = parseInt(x.css('top'));
        y.css('top', '19px');
        x.animate({top: t - 19 + 'px'}, 'slow');	//19为每个li的高度
        if (Math.abs(t) == h - 19) { //19为每个li的高度
            y.animate({top: '0px'}, 'slow');
            z = x;
            x = y;
            y = z;
        }
        setTimeout(b, 3000);//滚动间隔时间 现在是3秒
    }

    $(document).ready(function () {
        $('.swap').html($('.news_li').html());
        x = $('.news_li');
        y = $('.swap');
        h = $('.news_li li').length * 19; //19为每个li的高度
        setTimeout(b, 3000);//滚动间隔时间 现在是3秒

    })

</script>
<!--业务逻辑处理-->
<script>
    setTimeout(function () {
        addminute()
    }, 1000);
    function addminute(){
        /*先获取当前时间戳*/
        var intd = $('#now_time').val();
        intd = parseInt(intd);
        intd = (intd+1);
        $('#now_time').val(intd);
        /*再获取倒计时，时间*/
        var return_id = $("#return_id").val(), return_time = $("#return_time").val();
        var minus = return_time-intd;
        if(minus == 0){
            $(".good_"+return_id).find('span').html('匹配中');
            $(".good_"+return_id).find('span').removeAttr('onclick')
        }else{
            if(minus<30){
                $(".good_"+return_id).find('span').html('预约（'+minus+'秒)');
            }
            setTimeout(function () {
                addminute()
            }, 1000);
        }
    }
    /*一分钟刷新一次本页面  xuanfeng 20190621*/
    setTimeout(function() {
        window.location.reload();
    },120000);

    function buyproduct(id){
        if(id=='' || id==undefined){
            layer.alert('系統參數錯誤，請刷新後重試！',{shade:0.2});return false;
        }
        //点击哪一个图片就显示哪一个---start
        // if(id>0){
        //     var thatimg = $('.goodimg_'+id).attr('src');
        //     $('.giveimg').attr('src',thatimg);
        // }
        // //点击哪一个图片就显示哪一个---end
        // //设置预约产品的图片弹窗
        // var thatimg = $('.goodimg_'+id).attr('src');
        // $('.giveimg').attr('src',thatimg);
        // $(".ani_ac").show();//打开遮罩层
        // r1("预", "约");//打开預約中
        // $('.stips').html('恭喜，预约成功');
        layer.confirm('确定预约？', function (index) {
            $.ajax({
                type: 'POST',
                url: "{:url('Index/buyOrder')}",
                dataType: "json",
                data: "id="+id,
                success:function(responsestr){
                    var obj=responsestr;
                    if(obj.result_code== 0){
                        if(obj.result_data.type == 1){
                            //預約成功
                            $('.item_last'+id+" span").html('待匹配');
                            $('#return_id').val(0);
                            $('#return_time').val(0);
                            $('.item_last'+id+" span").removeAttr('onclick');
                            $('.apply_result').text('恭喜，成功预约');
                            $(".alert_ti").show()
                        }else{
                            //抢购成功
                        }
                        // r3();
                    }else{
                        // r2(obj.result_info);
                        $('.apply_result').text(obj.result_info);
                        $(".alert_ti").show()
                        return false;
                    }
                },
                error:function(){
                    // r2('当前访客较多，请稍后再试！','1.png');
                    layer.alert('当前访客较多，请稍后再试！');
                },
                complete:function () {
                    layer.close(index)
                }
            });
        })
    }

</script>